<%
'**************************************************************************************
sub Main()
	'this sub is the main controling procedure for the page for centralised code control

	'init the page
	call Initilise()
	
	'when done with the data deallocate
	'call Terminate()
	
end sub
'**************************************************************************************
sub Initilise()
	'this sub kicks off the page initilisation
		
	'connect to the database
	call DBConnect()
	
	set obj_Search = Server.CreateObject("KT_Search.clsSearch")
	
	
end sub
'**************************************************************************************

sub Terminate()
	'this sub is where all the objects for the page are deallocated
	set obj_ADOGetResponseDataProc = nothing
	set  obj_ADODirListRequests = nothing

	'ado connection object
	set obj_ADOConn = nothing
	set rsDirectiveData = nothing
	set rsGetResponseData = nothing
end sub
'**************************************************************************************

sub DBConnect()
	'this function connects to the database and sets the Conn object
	dim obj_ConnStr
	dim srtConnectionString
		
	'connect to the constring dll
	set obj_ConnStr = Server.createobject("connect.clsconnect") 
	'get the connectstring
	srtConnectionString = obj_ConnStr.ConnectionString 
	'deallocate the object
	set obj_ConnStr = nothing 
	'open the connection with the retrieved connection string from the dll
	set obj_ADOConn = server.CreateObject("ADODB.Connection")
	set obj_ADOConn2 = server.CreateObject("ADODB.Connection")
	set obj_ADOConn3 = server.CreateObject("ADODB.Connection")
	set obj_ADOConn4 = server.CreateObject("ADODB.Connection")
		
	obj_ADOConn.Open srtConnectionString
	obj_ADOConn2.Open srtConnectionString
	obj_ADOConn3.Open srtConnectionString
	obj_ADOConn4.Open srtConnectionString
	
end sub
'**************************************************************************************

sub CheckForNulls()
	
	if strKeyTaxReqNumber = isnull(rsDirectiveData("req_seq_num")) = true then
		strKeyTaxReqNumber = ""
	end if
	
	if isnull(rsDirectiveData("req_seq_num")) = true then
		strSARSFundNumber = ""
	end if
	'strEmployerPAYENumber = rsDirectiveData("req_seq_num")
	if isnull(rsGetResponseData("directive_number")) = true then
		strDirectiveNumber = ""
	end if
	
	if isnull(rsDirectiveData("sars_appl_id")) = true then
		strSARSApplicationNumber = ""
	end if
	
	if isnull(rsDirectiveData("Taxpayer")) = true then
		strTaxpayer = ""
	end if
	
	if isnull(rsDirectiveData("created_date")) = true then
		strRequestedDate = ""
	end if 
	
	if isnull(rsDirectiveData("created_by")) = true then
		strRequestedBy = ""
	end if
end sub
'**************************************************************************************

sub FillFields()
'this sub will fill variables with the data from the stored procs
	strDirectiveNumber = rsGetResponseData("directive_number")
	if strDirectiveNumber <> "In progress" then
		strKeyTaxReqNumber = rsDirectiveData("req_seq_num")
		strSARSFundNumber = rsDirectiveData("req_seq_num")
		'strEmployerPAYENumber = rsDirectiveData("req_seq_num")
		strSARSApplicationNumber = rsDirectiveData("sars_appl_id")
		strTaxpayer = rsDirectiveData("Taxpayer")
		strRequestedDate = rsDirectiveData("created_date")
		strRequestedBy = rsDirectiveData("created_by")
	end if
	
end sub
'**************************************************************************************

sub CreateADOObjects
	set obj_ADODirGetDirectiveDetailsProc = Server.CreateObject("ADODB.command")
	set obj_ADODirListRequests = Server.CreateObject("ADODB.command")
	set obj_ADOGetFundDetailsProc = Server.CreateObject("ADODB.command")
	set rsDirectiveData = Server.CreateObject("ADOR.Recordset")
	set rsGetResponseData = Server.CreateObject("ADOR.Recordset")
	set rsRequestList = Server.CreateObject("ADODB.Recordset")
	set rsFundDetails = Server.CreateObject("ADOR.Recordset")
	set obj_ADOGetEmployerIdDetails = Server.CreateObject("ADODB.command")
	set obj_ADOGetDirectiveDetails = Server.CreateObject("ADODB.Command")
	
end sub
'**************************************************************************************

%>